﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Magicodes.Admin.Migrations
{
    public partial class _1 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ArticleTagInfos_ArticleInfos_ArticleInfoId",
                table: "ArticleTagInfos");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ArticleTagInfos",
                table: "ArticleTagInfos");

            migrationBuilder.RenameTable(
                name: "ArticleTagInfos",
                newName: "ArticleTagInfo");

            migrationBuilder.RenameIndex(
                name: "IX_ArticleTagInfos_ArticleInfoId",
                table: "ArticleTagInfo",
                newName: "IX_ArticleTagInfo_ArticleInfoId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ArticleTagInfo",
                table: "ArticleTagInfo",
                column: "Id");

            migrationBuilder.CreateTable(
                name: "WULINGAddressses",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreatorUserId = table.Column<long>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    TenantId = table.Column<int>(nullable: true),
                    ServiceStationCode = table.Column<string>(nullable: true),
                    ServiceStationName = table.Column<string>(nullable: true),
                    PostCode = table.Column<string>(nullable: true),
                    Contact = table.Column<string>(nullable: true),
                    ContactPhoneNumber = table.Column<string>(nullable: true),
                    ReceiverAddress = table.Column<string>(nullable: true),
                    ServiceStationManager = table.Column<string>(nullable: true),
                    ServiceStationManagerPhoneNumber = table.Column<string>(nullable: true),
                    Area = table.Column<string>(nullable: true),
                    Province = table.Column<string>(nullable: true),
                    City = table.Column<string>(nullable: true),
                    District = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WULINGAddressses", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "SFOrders",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreatorUserId = table.Column<long>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    TenantId = table.Column<int>(nullable: true),
                    ServiceStationCode = table.Column<string>(nullable: true),
                    AddresId = table.Column<long>(nullable: true),
                    ShippingNumber = table.Column<string>(nullable: true),
                    Weight = table.Column<decimal>(nullable: false),
                    NumberOfCases = table.Column<int>(nullable: false),
                    Quantity = table.Column<decimal>(nullable: false),
                    ExpressProductType = table.Column<string>(nullable: false),
                    PaymentMethod = table.Column<string>(nullable: false),
                    MonthlyCardNumber = table.Column<string>(nullable: false),
                    CompanyName = table.Column<string>(nullable: true),
                    WhetherTheValuation = table.Column<string>(nullable: true),
                    DeclaredValue = table.Column<string>(nullable: true),
                    WhetherComeUndone = table.Column<string>(nullable: true),
                    IndustryOrientedValueAddedServices = table.Column<string>(nullable: true),
                    Note1 = table.Column<string>(nullable: true),
                    Note2 = table.Column<string>(nullable: true),
                    Note3 = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SFOrders", x => x.Id);
                    table.ForeignKey(
                        name: "FK_SFOrders_WULINGAddressses_AddresId",
                        column: x => x.AddresId,
                        principalTable: "WULINGAddressses",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_SFOrders_AddresId",
                table: "SFOrders",
                column: "AddresId");

            migrationBuilder.AddForeignKey(
                name: "FK_ArticleTagInfo_ArticleInfos_ArticleInfoId",
                table: "ArticleTagInfo",
                column: "ArticleInfoId",
                principalTable: "ArticleInfos",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ArticleTagInfo_ArticleInfos_ArticleInfoId",
                table: "ArticleTagInfo");

            migrationBuilder.DropTable(
                name: "SFOrders");

            migrationBuilder.DropTable(
                name: "WULINGAddressses");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ArticleTagInfo",
                table: "ArticleTagInfo");

            migrationBuilder.RenameTable(
                name: "ArticleTagInfo",
                newName: "ArticleTagInfos");

            migrationBuilder.RenameIndex(
                name: "IX_ArticleTagInfo_ArticleInfoId",
                table: "ArticleTagInfos",
                newName: "IX_ArticleTagInfos_ArticleInfoId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ArticleTagInfos",
                table: "ArticleTagInfos",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_ArticleTagInfos_ArticleInfos_ArticleInfoId",
                table: "ArticleTagInfos",
                column: "ArticleInfoId",
                principalTable: "ArticleInfos",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
